<?php

/**
 * Fichas filter form base class.
 *
 * @package    sbweb3
 * @subpackage filter
 * @author     Pablo Andrés Díaz
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseFichasFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'ficha_no'          => new sfWidgetFormFilterInput(),
      'biblioteca'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Biblioteca'), 'add_empty' => true)),
      'etiquetas_marc'    => new sfWidgetFormFilterInput(),
      'titulo'            => new sfWidgetFormFilterInput(),
      'autor'             => new sfWidgetFormFilterInput(),
      'clasificacion'     => new sfWidgetFormFilterInput(),
      'isbn'              => new sfWidgetFormFilterInput(),
      'fecha_publicacion' => new sfWidgetFormFilterInput(),
      'tipo_material'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TipoMaterial'), 'add_empty' => true)),
      'created_at'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'ficha_no'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'biblioteca'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Biblioteca'), 'column' => 'id')),
      'etiquetas_marc'    => new sfValidatorPass(array('required' => false)),
      'titulo'            => new sfValidatorPass(array('required' => false)),
      'autor'             => new sfValidatorPass(array('required' => false)),
      'clasificacion'     => new sfValidatorPass(array('required' => false)),
      'isbn'              => new sfValidatorPass(array('required' => false)),
      'fecha_publicacion' => new sfValidatorPass(array('required' => false)),
      'tipo_material'     => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('TipoMaterial'), 'column' => 'idtipomaterial')),
      'created_at'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('fichas_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Fichas';
  }

  public function getFields()
  {
    return array(
      'idficha'           => 'Number',
      'ficha_no'          => 'Number',
      'biblioteca'        => 'ForeignKey',
      'etiquetas_marc'    => 'Text',
      'titulo'            => 'Text',
      'autor'             => 'Text',
      'clasificacion'     => 'Text',
      'isbn'              => 'Text',
      'fecha_publicacion' => 'Text',
      'tipo_material'     => 'ForeignKey',
      'created_at'        => 'Date',
      'updated_at'        => 'Date',
    );
  }
}
